package com.thd.example.controller;

import com.thd.framework.basic.enums.ResultEnum;
import com.thd.framework.basic.model.Message;
import com.thd.framework.mail.dto.MailDto;
import com.thd.framework.mail.service.MailService;
import com.thd.framework.web.controller.BasicController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


@Controller
@RequestMapping("/example")
@Api("测试")
public class ExampleController extends BasicController {
    @Autowired
    private MailService mailService;
    @RequestMapping("/test")
    @ResponseBody
    @ApiOperation("test方法")
    public Message<String> test(){
        System.out.println(ResultEnum.SUCCESS.name());
        return Message.success(ResultEnum.SUCCESS.name());
    }


    @RequestMapping("/testMail")
    @ResponseBody
    @ApiOperation("testMail")
    public Message<String> testMail() throws Exception{
        MailDto dto = new MailDto();
        dto.setSubject("test");
        dto.setMailAddress(List.of("181907667@qq.com"));
        dto.setMessage("hello");
        mailService.sendMessage(dto);
        return Message.success(ResultEnum.SUCCESS.name());
    }



}
